<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  	<meta http-equiv="Cache-control" content="no-cache">
	<meta http-equiv="Cache" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet">
    <style type="text/css">
     .layui-layer-setwin .layui-layer-close2{
          right: -10px !important;
          top: 0px !important;
      }
      
      .layui-layer-self{
          background:transparent !important;
	      backgroundColor:transparent !important;
      }
    </style>
    <!-- 搜索样式CSS-Start -->
	<link href="/common/css/searchStyle.css" rel="stylesheet">
	<!-- 搜索样式CSS-End -->
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <!-- Example Events -->
                        <div class="example-wrap">
                                <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
				                	 	<form id="seachform">
					                	 	<div class="seach-context">
												 <label>功能代码 :</label><input id="funid" placeholder="请输入功能代码">
												 <label>功能名称 :</label><input id="fundesc" placeholder="请输入功能名称">
											</div> 
											<button id="resetBtn" type="button"  class="btn btn-w-m btn-white">重置</button>
					                		 <button id="addBtn" type="button"   power="ADDSYSFUN" class="btn btn-w-m btn-success">新增</button>
											 <button id="searchBtn" type="button"  class="btn btn-w-m btn-white">查询</button>
                                		 </form>
                                </div>
                                <table id="sysFunTable">
                                </table>
                            </div>
                        </div>
                        <!-- End Example Events -->
                    </div>
                </div>
            </div>
        </div>
        <!-- End Panel Other -->
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/common/bootstrap-table-treetable.js"></script>
   	<script src="/common/petecat.js"></script>
   	<script src="/common/bootstrap-table.js"></script>
   	<script src="/common/form.js"></script>
   	<script src="/js/plugins/layer-pc/layer.js"></script>
   	<script src="/js/jquery.cookie.js"></script>
    <script type="text/javascript">
    checkPowerAndJump("QRYSYSFUN");
    var parentNameWin = null;
    $(function(){
    	$('#resetBtn').click(function(){
    		$('#seachform').resetForm();
    	});
    	$('#addBtn').click(function(){
    		layer.open({
    			type: 2,
    		    title: '新增系统权限',
    		    shade: 0.8,
    		    area: ['380px', '80%'],
    		    content: ['/user/sysfun/add.html', 'auto'], //iframe的url，no代表不显示滚动条
    		    end: function(){ //此处用于演示
    		    	refreshGrid('sysFunTable');
    		    },
    		    success:function(layero){
    		    	parentNameWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
    		    }
    		});
    	});
    	
    	 var treeTable = {
    	    id:'sysFunTable',
    	    idField:'funid',
    	    uniqueId:'funid',
    	    queryParams:function(){
    	    	var queryParams={};
        		queryParams.funid = $('#funid').val();
        		queryParams.fundesc = $('#fundesc').val();
        		return queryParams;
        	},
    	    url:SSO_URL+'/sy/sysfun/queryFunTree',
    	    columns:[{
	    		 expanded:true,
	    		field:'funid',
	    		title:'功能代码'
	    	},{
	    		field:'fundesc',
	    		title:'功能名称'
	    	},{
	    		field :'botflag',
	    		title:'是否菜单',
	    		formatter:function(value,row,index){
	    			return value == 0? '否':'是';
	    		}
	    	},{
	    		field :'useflag',
	    		title:'是否使用',
	    		formatter:function(value,row,index){
	    			return value == 0? '否':'是';
	    		}
	    	},{
	    		field :'displayfun',
	    		title:'显示菜单权限',
	    		formatter:function(value,row,index){
	    			return value == 0? '否':'是';
	    		}
	    	},{
	    		field :'orderval',
	    		title:'排序值'
	    	},{
	        	field : "opt",
	        	title:"操作",
	        	width: 200,
	        	formatter: function(value, row, index) {
	        		 var html = "";
	       		     if(checkPower("MODSYSFUN")){
	       			 html+='<a class="edit" href="javascript:void(0)" title="修改">修改</a>&nbsp;&nbsp;&nbsp;';
	       		     }
					 if(checkPower("DELSYSFUN")){
						 html+= '<a class="del" href="javascript:void(0)" title="删除">删除</a>&nbsp;&nbsp;&nbsp;';
					 }
					 return html;
	        	},
	        	events:{
	        		'click .edit':function(e, value, row, index){
	        			layer.open({
	            			type: 2,
	            		    title: '修改权限',
	            		    shade: 0.8,
	            		    area: ['380px', '80%'],
	            		    content: ['/user/sysfun/edit.html', 'auto'], //iframe的url，no代表不显示滚动条
	            		    end: function(){ //此处用于演示
	            		    	refreshGrid('sysFunTable');
	            		    },
	            		    success:function(layers,index){
	            		    	var body = layer.getChildFrame('body', index);
	            		    	var FormOptions = {};
	            		    	FormOptions['jsonValue'] = row;
	            		    	body.find('#signupForm').initForm(FormOptions);
	            		    	var iframeWin = window[layers.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
	            		    	iframeWin.setInitData(row);
	            		    	parentNameWin=iframeWin;
	            		    }
	            		});
	        		},
	        		'click .del':function(e, value, row, index){
	        			layer.confirm('是否将当前权限删除', {
	      					btn: ['是','否'] //按钮
	       				}, function(){
	    		        	var req = {};
	    		        	req['reqJSON'] = {
	    	        			type : 'delete',
	    	        			url : SSO_URL+'/sy/sysfun/deleteFun?funid='+row.funid,
	    	        			data : {}
	    		        	};
	    		        	req['successFn'] = function(respData){
	    		        		layer.msg(respData.message, {icon: 6},function(){
	            				}); 
	    		        		if(respData.code == SUCCESS_CODE){
	    		        			refreshGrid('sysFunTable');
	        					}
	    		        	};
	    		        	ajaxRequest(req);
	       				});
	        		}
	        	}
	        }]
        };
    	initTableTree(treeTable);
    	$('#searchBtn').click(function(){
    		refreshGrid('sysFunTable');
    	});
    });
    </script>
</body>
</html>